define([
        'app',
        'api/PingppAPI'
    ],
    function (app) {
        'use strict';
        app.factory('PayAPI', ['API', '$resource', '$rootScope', '$location',
            function (API, $resource, $rootScope, $location) {
                var payServer;
                if ($location.host().toLowerCase().indexOf('malianghang.com') !== -1) {
                    payServer = 'http://pay.m-lab.cn/live';
                } else {
                    payServer = 'http://mpayment.avosapps.com/test';
                }
                return {
                    createOrder: function (orderData) {
                        var order = angular.copy(orderData);
                        return $resource(payServer + '/order').save(
                            order
                        ).$promise;
                    }
                };
            }
        ]);
    }
);
